package demo1;

/**
 * @author 24岁没牵过女人的手
 * 日期：2023/6/19 16:13
 * 文件描述：
 */
public abstract class Duck {
    QuackBehavior quackBehavior;
    FlyBehavior flyBehavior;

    public Duck(QuackBehavior quackBehavior, FlyBehavior flyBehavior) {
        this.quackBehavior = quackBehavior;
        this.flyBehavior = flyBehavior;
    }

    public void setFlyBehavior(FlyBehavior fb){
        flyBehavior = fb;
    }

    public void setQuackBehavior(QuackBehavior qb){
        quackBehavior = qb;
    }

    /**
     * 不同的鸭子不一样都是独一无二的，共同点少
     */
    public abstract void disPlay();
    public void swim(){
        System.out.println("游泳🏊‍");
    }

    public void performQuack(){
        quackBehavior.quack();
    }

    public void performFly(){
        flyBehavior.fly();
    }

}
